from re_common.baselibrary.utils.basehttpx import BaseHttpx
from re_common.baselibrary.utils.core.requests_core import USER_AGENT


def get_session():
    """
    creat_sn里的两个参数
    proxy: 为空则是本身ip
    headers：为空则是自动添加一个user-agent
    :return:
    """
    bshttpx = BaseHttpx()
    print(bshttpx.sn)
    print("******************")
    bshttpx.creat_sn(proxy="",
                     headers="")
    print(bshttpx.sn)
    print("*************")
    url = "https://www.ip.cn/"
    BoolResult, errString, r = bshttpx.base_sn_httpx(url,
                                                     bshttpx.sn)
    print(r.text)

def set_session_argument():
    bshttpx = BaseHttpx()

    HEADERS = {'Accept': '*/*',
               'Accept-Encoding': 'gzip, deflate',
               'User-Agent': USER_AGENT,
               'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8'}
    bshttpx.creat_sn(proxy="192.168.31.176:8012",
                     headers=HEADERS)

    url = "https://www.ip.cn/"
    BoolResult, errString, r = bshttpx.base_sn_httpx(url,
                                                     bshttpx.sn)
    print(r)

if __name__ == '__main__':
    # get_session()
    set_session_argument()

